package cn.tedu.test.luban.demo.condition.config;

import cn.tedu.test.luban.demo.annotaion.ConditionalOnLinux;
import cn.tedu.test.luban.demo.annotaion.ConditionalOnWindows;
import cn.tedu.test.luban.demo.bean.Bean01;
import cn.tedu.test.luban.demo.bean.Bean04;
import cn.tedu.test.luban.demo.condition.OnOtherOSCondition;
import cn.tedu.test.luban.demo.condition.OnWindowsCondition;
import org.springframework.boot.autoconfigure.condition.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

@Configuration
@ConditionalOnProperty(
        prefix = "luban",
        value="user.name",
        havingValue = "wangcuihua",
        matchIfMissing = true
)
//@ConditionalOnWindows
//1. 如果环境中能找到com.aaa.Abc 条件满足
//@ConditionalOnClass(name = {"com.aaa.Abc"})
//2. 如果环境中不能找到com.aaa.Abc 条件满足
//@ConditionalOnMissingClass(value = {"com.aaa.Abc"})
//3. 如果容器中已存在一个com.aaa.Abc的bean对象 条件满足
//@ConditionalOnBean(type="com.aaa.Abc")
//4. 如果容器中不存在一个com.aaa.Abc的bean对象 条件满足
//@ConditionalOnMissingBean(type="com.aaa.Abc")
public class MyConditionConfig01 {
    public MyConditionConfig01() {
        System.out.println("当前条件config01条件满足 被容器加载");
    }
    @Bean
    //@ConditionalOnLinux
    public Bean04 bean04(){
        return new Bean04();
    }
}
